package com.kmist.xiakexing.presenters;

import com.kmist.xiakexing.data.ItemDao;
import com.kmist.xiakexing.interfaces.IItemCallback;
import com.kmist.xiakexing.interfaces.IItemPresenter;
import com.kmist.xiakexing.utils.scene.ItemBean;
import com.kmist.xiakexing.utils.scene.MapBean;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;

public class ItemPresenter implements IItemPresenter {

    private final ItemDao itemDao = null;
    private static ItemPresenter sInstance = null;
    private List<IItemCallback> itemCallbacks = new ArrayList<>();

    public ItemPresenter() {
        //itemDao = ItemDao.getInstance();
        //itemDao.setCallback();
    }

    public static ItemPresenter getsInstance() {
        if(sInstance == null){
            synchronized (ItemPresenter.class){
                sInstance = new ItemPresenter();
            }
        }
        return sInstance;
    }

    @Override
    public void addItem(ItemBean itemBean) {

    }

    @Override
    public void addItemList(List<ItemBean> itemBeans) {

    }

    @Override
    public void delItem(ItemBean itemBean) {

    }


    @Override
    public void registerViewCallback(IItemCallback callback) {
        if(!itemCallbacks.contains(callback)){
            itemCallbacks.add(callback);
        }
    }

    @Override
    public void unRegisterViewCallback(IItemCallback callback) {
        itemCallbacks.remove(callback);
    }
}
